﻿<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">

  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="/">
    <SalesDoc>
      <xsl:for-each select="root/eConnect/SO_Trans">
        <Type>
          <xsl:if test="SOPTYPE = '1'">Quote</xsl:if>
          <xsl:if test="SOPTYPE = '2'">Order</xsl:if>
          <xsl:if test="SOPTYPE = '3'">Invoice</xsl:if>
          <xsl:if test="SOPTYPE = '4'">Return</xsl:if>
          <xsl:if test="SOPTYPE = '5'">BackOrder</xsl:if>
          <xsl:if test="SOPTYPE = '6'">FulfillmentOrder</xsl:if>
        </Type>
        <TypeID>
          <xsl:value-of select="DOCID"/>
        </TypeID>
        <DocumentID>
          <xsl:value-of select="SOPNUMBE"/>
        </DocumentID>
        <Date>
          <xsl:value-of select="DOCDATE"/>
        </Date>
        <Customer>
          <CustomerID>
            <xsl:value-of select="CUSTNMBR"/>
          </CustomerID>
          <Name>
            <xsl:value-of select="CUSTNAME"/>
          </Name>
          <ShortName>
            <xsl:value-of select="ABC"/>
          </ShortName>
          <StatementName>
            <xsl:value-of select="ABC"/>
          </StatementName>
          <Address>
            <AddressID>
              <xsl:value-of select="ABC"/>
            </AddressID>
            <Contact>
              <xsl:value-of select="ABC"/>
            </Contact>
            <Address1>
              <xsl:value-of select="ABC"/>
            </Address1>
            <Address2>
              <xsl:value-of select="ABC"/>
            </Address2>
            <City>
              <xsl:value-of select="ABC"/>
            </City>
            <State>
              <xsl:value-of select="ABC"/>
            </State>
            <Zip>
              <xsl:value-of select="ABC"/>
            </Zip>
            <Country>
              <xsl:value-of select="ABC"/>
            </Country>
            <Phone1>
              <xsl:value-of select="ABC"/>
            </Phone1>
            <Fax>
              <xsl:value-of select="ABC"/>
            </Fax>
          </Address>
          <EMail>
            <xsl:value-of select="ABC"/>
          </EMail>
        </Customer>
        <CustomerPONumber>
          <xsl:value-of select="CSTPONBR"/>
        </CustomerPONumber>
        <BatchID>
          <xsl:value-of select="BACHNUMB"/>
        </BatchID>
        <BatchSource>
          <xsl:value-of select="BCHSOURC"/>
        </BatchSource>
        <SalesRepID>
          <xsl:value-of select="SLPRSNID"/>
        </SalesRepID>
        <OrignalType>
          <xsl:value-of select="ORIGTYPE"/>
        </OrignalType>
        <OrignalDocumentID>
          <xsl:value-of select="ORIGNUMB"/>
        </OrignalDocumentID>
        <SiteID>
          <xsl:value-of select="LOCNCODE"/>
        </SiteID>
        <BatchSource>
          <xsl:value-of select="BCHSOURC"/>
        </BatchSource>
        <BillingAddress>
          <AddressID>
            <xsl:value-of select="PRBTADCD"/>
          </AddressID>
          <Contact>
            <xsl:value-of select="ABC"/>
          </Contact>
          <Address1>
            <xsl:value-of select="ABC"/>
          </Address1>
          <Address2>
            <xsl:value-of select="ABC"/>
          </Address2>
          <City>
            <xsl:value-of select="ABC"/>
          </City>
          <State>
            <xsl:value-of select="ABC"/>
          </State>
          <Zip>
            <xsl:value-of select="ABC"/>
          </Zip>
          <Country>
            <xsl:value-of select="ABC"/>
          </Country>
          <Phone1>
            <xsl:value-of select="ABC"/>
          </Phone1>
          <Fax>
            <xsl:value-of select="ABC"/>
          </Fax>
        </BillingAddress>
        <ShippingAddress>
          <AddressID>
            <xsl:value-of select="PRSTADCD"/>
          </AddressID>
          <Contact>
            <xsl:value-of select="CNTCPRSN"/>
          </Contact>
          <Address1>
            <xsl:value-of select="ADDRESS1"/>
          </Address1>
          <Address2>
            <xsl:value-of select="ADDRESS2"/>
          </Address2>
          <City>
            <xsl:value-of select="CITY"/>
          </City>
          <State>
            <xsl:value-of select="STATE"/>
          </State>
          <Zip>
            <xsl:value-of select="ZIPCODE"/>
          </Zip>
          <Country>
            <xsl:value-of select="COUNTRY"/>
          </Country>
          <Phone1>
            <xsl:value-of select="PHNUMBR1"/>
          </Phone1>
          <Fax>
            <xsl:value-of select="FAXNUMBR"/>
          </Fax>
        </ShippingAddress>
        <ShippingMethod>
          <xsl:value-of select="SHIPMTHD"/>
        </ShippingMethod>
        <FreightAmount>
          <xsl:value-of select="FRTAMNT"/>
        </FreightAmount>
        <MiscAmount>
          <xsl:value-of select="MISCAMNT"/>
        </MiscAmount>
        <MarkDownTotal>
          <xsl:value-of select="MRKDNAMT"/>
        </MarkDownTotal>
        <TradeDiscount>
          <xsl:value-of select="TRDISAMT"/>
        </TradeDiscount>
        <Subtotal>
          <xsl:value-of select="SUBTOTAL"/>
        </Subtotal>
        <TaxAmount>
          <xsl:value-of select="TAXAMNT"/>
        </TaxAmount>
        <Total>
          <xsl:value-of select="DOCAMNT"/>
        </Total>
        <PaymentReceived>
          <xsl:value-of select="PYMTRCVD"/>
        </PaymentReceived>
        <TaxScheduleID>
          <xsl:value-of select="TAXSCHID"/>
        </TaxScheduleID>
        <PaymentTerms>
          <xsl:value-of select="PYMTRMID"/>
        </PaymentTerms>
        <PriceLevel>
          <xsl:value-of select="PRCLEVEL"/>
        </PriceLevel>
      </xsl:for-each>
      <LineItems>
        <xsl:for-each select="root/eConnect/SO_Trans/Line">
          <LineItem>
            <Sequence>
              <xsl:value-of select="LNITMSEQ"/>
            </Sequence>
            <ItemID>
              <xsl:value-of select="ITEMNMBR"/>
            </ItemID>
            <Description>
              <xsl:value-of select="ITEMDESC"/>
            </Description>
            <SiteID>
              <xsl:value-of select="LOCNCODE"/>
            </SiteID>
            <Quantity>
              <xsl:value-of select="QUANTITY"/>
            </Quantity>
            <UOM>
              <xsl:value-of select="UOFM"/>
            </UOM>
            <Name>
              <xsl:value-of select="ITEMDESC"/>
            </Name>
            <MarkDown>
              <xsl:value-of select="MRKDNAMT"/>
            </MarkDown>
            <ExtendedPrice>
              <xsl:value-of select="XTNDPRCE"/>
            </ExtendedPrice>
            <Quantity>
              <xsl:value-of select="QUANTITY"/>
            </Quantity>
            <Taxable>
              <xsl:value-of select="IVITMTXB"/>
            </Taxable>
            <UnitPrice>
              <xsl:value-of select="UNITPRCE"/>
            </UnitPrice>
            <TaxAmount>
              <xsl:value-of select="TAXAMNT"/>
            </TaxAmount>
            <NonInventory>
              <xsl:value-of select="NONINVEN"/>
            </NonInventory>
          </LineItem>
        </xsl:for-each>
      </LineItems>
      <PaymentLines>
        <xsl:for-each select="root/eConnect/SO_Trans/Payments">
          <PaymentLine>
            <Sequence>
              <xsl:value-of select="SEQNUMBR"/>
            </Sequence>
            <TrxAmount>
              <xsl:value-of select="AMNTPAID"/>
            </TrxAmount>
            <CCType>
              <xsl:value-of select="CARDNAME"/>
            </CCType>
            <CCNumber>
              <xsl:value-of select="RCTNCCRD"/>
            </CCNumber>
            <CCExpDate>
              <xsl:value-of select="EXPNDATE"/>
            </CCExpDate>
            <AuthCode>
              <xsl:value-of select="AUTHCODE"/>
            </AuthCode>
            <CheckBookID>
              <xsl:value-of select="CHEKBKID"/>
            </CheckBookID>
            <CheckNumber>
              <xsl:value-of select="CHEKNMBR"/>
            </CheckNumber>
            <PaymentType>
              <xsl:value-of select="PYMTTYPE"/>
            </PaymentType>
          </PaymentLine>
        </xsl:for-each>
      </PaymentLines>
    </SalesDoc>
  </xsl:template>
</xsl:stylesheet>
